<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    html, body{
      padding: 0;
      margin: 0;
      width: 100%;
      height: 100%;
      background-color: rgb(54, 66, 73);
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .wrapper{
      width: 100%;
      height: 200px;
      border: 1px solid red;

      position: relative;
    }

    ul{
      margin: 0px;
      padding: 0;
      list-style: none;

      position: relative;
    }

    li{
      position: absolute;
      top: 0px;
      left: 0px;
      width: 100%;
      height: 100%;
      border: 1px solid white;
      background-color: rgb(87, 211, 211, 0.6);
    }

    .inner-box{
      width: 100px;
      height: 100px;
      /* background-color: rgb(87, 211, 211, 0.6); */

      position: absolute;
      top: 50%;
      left: 50%;
      margin: -50px 0 0 -50px;
      
      /* 开启3d */
      transform-style: preserve-3d;
      transform: rotateX(-33.5deg) rotateY(45deg);

      /* 帧动画 */
      animation: innerLoop 6s ease-in-out infinite;
    }
    @keyframes innerLoop{
      0%{
        transform: rotateX(-33.5deg) rotateY(45deg);
      }
      /* 到50%的时候已经旋转结束，花费了一半的事件3s。剩下的3s到100%一直停留在原地 */
      /* 逆时针旋转度就是-360+45=-315 */
      50%, 100%{
        transform: rotateX(-33.5deg) rotateY(-315deg);
      }
    }
    .inner-box .top{
      transform: rotateX(90deg) translateZ(50px);
    }
    .inner-box .bottom{
      transform: rotateX(-90deg) translateZ(50px);
    }
    .inner-box .left{
      transform: rotateY(-90deg) translateZ(50px);
    }
    .inner-box .right{
      transform: rotateY(90deg) translateZ(50px);
    }
    .inner-box .front{
      transform: translateZ(50px);
    }
    .inner-box .back{
      transform: rotateY(180deg) translateZ(50px);
    }


    .outer-box{
      width: 200px;
      height: 200px;
       /* background-color: rgb(87, 211, 211, 0.6); */

      position: absolute;
      top: 50%;
      left: 50%;
      margin: -100px 0 0 -100px;
      
      /* 开启3d */
      transform-style: preserve-3d;
      transform: rotateX(-33.5deg) rotateY(45deg);
      /* ease-in-out表示先慢载快再慢，linear表示匀速  infinite表示无限循环*/
      animation: outerLoop 6s ease-in-out infinite;  
    }

    @keyframes outerLoop {
      /* 0%的状态 */
      0% {
        transform: rotateX(-33.5deg) rotateY(45deg);
      }
      /* 顺时针旋转360度就是360-45=315 */
      50%, 100%{
        transform: rotateX(-33.5deg) rotateY(405deg);
      }
    }

    .outer-box .li{
      background-color: rgb(87, 211, 211, 0.5);
    }

    .outer-box .top{
      transform: rotateX(90deg) translateZ(100px);
    }
    .outer-box .bottom{
      transform: rotateX(-90deg) translateZ(100px);
    }
    .outer-box .left{
      transform: rotateY(-90deg) translateZ(100px);
    }
    .outer-box .right{
      transform: rotateY(90deg) translateZ(100px);
    }
    .outer-box .front{
      transform: translateZ(100px);
    }
    .outer-box .back{
      transform: rotateY(180deg) translateZ(100px);
    }
  </style>
</head>
<body>
  <div class="wrapper">
    <!-- 小盒子 -->
    <ul class="inner-box">
      <li class="top">上</li>
      <li class="bottom">下</li>
      <li class="left">左</li>
      <li class="right">右</li>
      <li class="front">前</li>
      <li class="back">后</li>
    </ul>
    <!-- 大盒子 -->
    <ul class="outer-box">
      <li class="top">上</li>
      <li class="bottom">下</li>
      <li class="left">左</li>
      <li class="right">右</li>
      <li class="front">前</li>
      <li class="back">后</li>
    </ul>
  </div>
</body>
</html>